class Animal:
    pass

# 继承：Dog类继承自父类Animal
class Dog(Animal):
    pass

# 学生继承关系示例
class Student:
    """学生类"""

    def __init__(self,name,age,student_id):
        """初始化方法"""
        self.name = name
        self.age = age
        self.student_id = student_id

    def get_info(self):
        """获取学生信息"""
        return f"学生姓名：{self.name}，年龄：{self.age}，学号：{self.student_id}"


class Mstudent(Student):
    """中学生类"""

    def __init__(self,name,age,student_id,grade):
        """初始化方法"""
        # 调用父类的初始化方法
        super().__init__(name,age,student_id)
        # 添加新的属性
        self.grade = grade

    def get_info(self):
        """获取学生信息"""
        return super().get_info() + f"，年级：{self.grade}"

class Cstudent(Student):
    """大学生类"""

    def __init__(self,name,age,student_id,major):
        """初始化方法"""
        # 调用父类的初始化方法
        super().__init__(name,age,student_id)
        # 添加新的属性
        self.major = major

    def get_info(self):
        """获取学生信息"""
        return super().get_info() + f"，专业：{self.major}"

m1 = Mstudent("小王",15,20210001,9)
print(m1.get_info())
c1 = Cstudent("李四",21,20210001,"软件工程")
print(c1.get_info())


print("=" * 50)
# 多继承
class Phone:
    """手机类"""
    def call(self):
        return "打电话"

class Camera:
    """相机类"""
    def take_photo(self):
        return "拍照"

class GPS:
    """GPS类"""
    def get_location(self):
        return "定位位置信息"

class SmartPhone(Phone, Camera, GPS):
    """智能手机类"""
    def __init__(self, brand):
        self.brand = brand


# 实例化智能手机
s1 = SmartPhone("华为")
print(s1.brand + "智能手机：" + s1.call())
print(s1.brand + "智能手机：" + s1.take_photo())
print(s1.brand + "智能手机：" + s1.get_location())


print("=" * 50)
# 重写父类方法
class Animal:
    """动物类"""
    def eat(self):
        """吃"""
        return "吃吃吃"
    def sleep(self):
        """睡觉"""
        return "睡觉睡觉"

class Dog(Animal):
    """狗类"""

    def eat(self):
        """吃"""
        return "吃骨头"
    def sleep(self):
        """睡觉"""
        # 使用super()可以调用父类中的方法
        return "汪汪汪：" + super().sleep()

a = Animal()
dog = Dog()
print("Animal:", a.eat())
print("Animal:", a.sleep())
print("Dog:", dog.eat())
print("Dog:", dog.sleep())

print("=" * 50)
# 多态与鸭子类型
class Drawable:
    """绘制接口"""
    def draw(self):
        """绘制方法"""
        pass

class Circle(Drawable):
    """圆形类"""
    def draw(self):
        """绘制圆形"""
        return "绘制圆形"

class Square(Drawable):
    """正方形类"""
    def draw(self):
        """绘制正方形"""
        return "绘制正方形"

class Brush:
    """笔类"""
    def draw(self):
        """绘制方法"""
        return "我是一只笔刷，可以绘制很多东西哦！！！"

def draw_shape(shape: Drawable):
    """绘制形状"""
    return shape.draw()

c = Circle()
s = Square()
b = Brush()
print(draw_shape(c))    # 绘制圆形
print(draw_shape(s))    # 绘制正方形
print(draw_shape(b))    # 我是一只笔刷，可以绘制很多东西哦！！！
